{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "cb9e3f4a",
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "[[ 1.2239866   0.6865971  -1.0540441   0.47637084  0.26875976 -0.2254785\n",
      "   0.20388725  0.5090486   0.19365953  1.8286113 ]\n",
      " [-0.17279942  0.3016165   1.0519212   0.22847903 -1.6276437  -1.5162636\n",
      "  -0.8950284   1.0308307  -0.6303643   1.9787396 ]]\n",
      "<NDArray 2x10 @cpu(0)>\n",
      "epoch 1,loss 9.825177\n",
      "epoch 2,loss 9.531800\n",
      "epoch 3,loss 9.097032\n",
      "epoch 4,loss 9.315472\n",
      "epoch 5,loss 9.062702\n",
      "epoch 6,loss 9.484208\n",
      "epoch 7,loss 9.276781\n",
      "epoch 8,loss 9.174507\n",
      "epoch 9,loss 9.491229\n",
      "epoch 10,loss 9.303699\n",
      "epoch 11,loss 8.959337\n",
      "epoch 12,loss 9.476478\n",
      "epoch 13,loss 9.832876\n",
      "epoch 14,loss 9.288417\n",
      "epoch 15,loss 9.375965\n",
      "epoch 16,loss 9.432245\n",
      "epoch 17,loss 9.115584\n",
      "epoch 18,loss 9.926882\n",
      "epoch 19,loss 9.182493\n",
      "epoch 20,loss 9.632247\n",
      "epoch 21,loss 9.098592\n",
      "epoch 22,loss 9.080652\n",
      "epoch 23,loss 9.685481\n",
      "epoch 24,loss 9.676061\n",
      "epoch 25,loss 9.259063\n",
      "epoch 26,loss 9.199054\n",
      "epoch 27,loss 9.519471\n",
      "epoch 28,loss 9.254549\n",
      "epoch 29,loss 9.177516\n",
      "epoch 30,loss 9.142916\n",
      "epoch 31,loss 9.496697\n",
      "epoch 32,loss 9.210734\n",
      "epoch 33,loss 9.181821\n",
      "epoch 34,loss 9.405343\n",
      "epoch 35,loss 9.451435\n",
      "epoch 36,loss 9.524625\n",
      "epoch 37,loss 9.011776\n",
      "epoch 38,loss 8.994988\n",
      "epoch 39,loss 9.269760\n",
      "epoch 40,loss 9.380391\n",
      "epoch 41,loss 9.024049\n",
      "epoch 42,loss 9.552214\n",
      "epoch 43,loss 9.218199\n",
      "epoch 44,loss 9.431792\n",
      "epoch 45,loss 9.348729\n",
      "epoch 46,loss 9.259995\n",
      "epoch 47,loss 9.439266\n",
      "epoch 48,loss 9.070390\n",
      "epoch 49,loss 9.211065\n",
      "epoch 50,loss 9.140943\n"
     ]
    }
   ],
   "source": [
    "%matplotlib inline\n",
    "import d2lzh as d2l\n",
    "import xlrd\n",
    "import random\n",
    "import math\n",
    "from IPython import display\n",
    "from matplotlib import pyplot as plt\n",
    "from mxnet import autograd, nd\n",
    "batch_size = 3\n",
    "num_inputs = 2\n",
    "num_outputs = 1\n",
    "num_hiddens=10\n",
    "\n",
    "\n",
    "num_examples = 1000\n",
    "true_w = [2, -3.4]\n",
    "true_b = 4.2\n",
    "features = nd.random.normal(scale=1, shape=(num_examples, num_inputs))\n",
    "labels = true_w[0] * features[:, 0] + true_w[1] * features[:, 1] + true_b\n",
    "labels += nd.random.normal(scale=0.01, shape=labels.shape)\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "w = nd.random.normal(scale=1, shape=(num_inputs, num_hiddens))\n",
    "b = nd.zeros(num_hiddens)\n",
    "w1=nd.random.normal(scale=1, shape=(num_hiddens, num_outputs))\n",
    "b1= nd.zeros(num_outputs)\n",
    "\n",
    "w.attach_grad()\n",
    "b.attach_grad()\n",
    "w1.attach_grad()\n",
    "b1.attach_grad()\n",
    "\n",
    "params=[w,b,w1,b1]\n",
    "print(w)\n",
    "# def use_svg_display():\n",
    "#     # 用矢量图显示\n",
    "#     display.set_matplotlib_formats('svg')\n",
    "\n",
    "# def set_figsize(figsize=(3.5, 2.5)):\n",
    "#     use_svg_display()\n",
    "#     # 设置图的尺寸\n",
    "#     plt.rcParams['figure.figsize'] = figsize\n",
    "\n",
    "def squared_loss(y_hat, y):\n",
    "    return (y_hat - y) ** 2 / 2\n",
    "\n",
    "def relu(X):\n",
    "    return nd.maximum(X,0)\n",
    "\n",
    "def net(X):\n",
    "    H=relu(nd.dot(X,w)+b)\n",
    "    Y=nd.dot(H, w1) + b1\n",
    "    return Y\n",
    "\n",
    "def excel2matrix(path):\n",
    "    data = xlrd.open_workbook(path)\n",
    "    table = data.sheets()[0]\n",
    "    nrows = table.nrows  # 行数\n",
    "    ncols = table.ncols  # 列数\n",
    "    datamatrix = nd.random.normal(scale=1,shape=(nrows, ncols))\n",
    "    for i in range(nrows):\n",
    "        rows = table.row_values(i)\n",
    "        datamatrix[i,:] = rows\n",
    "    return datamatrix\n",
    " \n",
    "def data_iter(batch_size, features, labels):\n",
    "    num_examples = len(features)\n",
    "    indices = list(range(num_examples))\n",
    "    random.shuffle(indices)  # 样本的读取顺序是随机的\n",
    "    for i in range(0, num_examples, batch_size):\n",
    "        j = nd.array(indices[i: min(i + batch_size, num_examples)])\n",
    "        yield features.take(j), labels.take(j)  # take函数根据索引返回对应元素\n",
    "# def cross_entropy(y_hat, y):\n",
    "#     return -nd.pick(y_hat, y).log()\n",
    "# def accuracy(y_hat, y):\n",
    "#     return (y_hat.argmax(axis=1) == y.astype('float32')).mean().asscalar()\n",
    "\n",
    "# def evaluate_accuracy(data_iter, net):\n",
    "#     acc_sum, n = 0.0, 0\n",
    "#     for X, y in data_iter:\n",
    "#         y = y.astype('float32')\n",
    "#         acc_sum += (net(X).argmax(axis=1) == y).sum().asscalar()\n",
    "#         n += y.size\n",
    "#     return acc_sum / n\n",
    "\n",
    "num_epochs, lr = 50, 0.001\n",
    "\n",
    "def sgd(params, lr, batch_size):  \n",
    "    for param in params:\n",
    "        param[:] = param - lr * param.grad / batch_size\n",
    "\n",
    "def train_ch3(net, train_iter, test_iter, loss, num_epochs, batch_size,\n",
    "              params=None, lr=None):\n",
    "    for epoch in range(num_epochs):\n",
    "        for X, y in data_iter(batch_size,features,labels):\n",
    "            with autograd.record():\n",
    "                y_hat = net(X)\n",
    "#                 print('X')\n",
    "#                 print(X)\n",
    "#                 print('y_hat')\n",
    "#                 print(y_hat)\n",
    "#                 print('y')\n",
    "#                 print(y)\n",
    "#                 print('[W,b]')\n",
    "#                 print([w,b])\n",
    "                l = loss(y_hat, y)\n",
    "            l.backward()   #求梯度\n",
    "            sgd(params, lr, batch_size)    #更新wb权重   \n",
    "#         print(params)\n",
    "        train_l_sum =loss(net(features),labels)  #误差\n",
    "        print('epoch %d,loss %f' % (epoch + 1,train_l_sum.mean().asnumpy()))\n",
    "\n",
    "\n",
    "pathX = '309.xls'  #  113.xlsx 在当前文件夹下\n",
    "pathX2 = '309_label.xls'  #  113.xlsx 在当前文件夹下\n",
    "pathX3 = '309_pre.xls'  #  113.xlsx 在当前文件夹下\n",
    "x = excel2matrix(pathX)\n",
    "x_label=excel2matrix(pathX2)\n",
    "y_test=excel2matrix(pathX3)\n",
    "y_label=nd.zeros((y_test.shape[0],1))\n",
    "\n",
    "train_iter=data_iter(batch_size,features,labels)\n",
    "test_iter=data_iter(batch_size,y_test,y_label)\n",
    "train_ch3(net, train_iter, test_iter, squared_loss, num_epochs, batch_size,params, lr)\n",
    "#set_figsize()\n",
    "#plt.scatter(x[:, 1].asnumpy(), x_label[:, 0].asnumpy(), 1);  # 加分号只显示图\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "e86025e9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[\n",
      "[[-1.4893516e+00 -4.5142703e+14 -5.2203663e+14  3.2085025e-01\n",
      "  -5.4705167e-01]\n",
      " [-5.0163102e-01 -1.6349226e+13 -1.8906480e+13  4.0055764e-01\n",
      "  -7.2957677e-01]\n",
      " [ 5.8491018e-02 -5.0282169e+14 -5.8147012e+14 -1.5523086e+00\n",
      "  -1.5681125e+00]\n",
      " [ 1.0746684e+00 -6.7949214e+13 -7.8577450e+13 -1.3414803e+00\n",
      "   1.7259893e-01]]\n",
      "<NDArray 4x5 @cpu(0)>, \n",
      "[ 0.000000e+00 -6.843905e+13 -7.914389e+13  0.000000e+00  0.000000e+00]\n",
      "<NDArray 5 @cpu(0)>]\n"
     ]
    }
   ],
   "source": [
    "print([w,b])\n",
    "a=net(y_test)\n",
    "\n",
    "set_figsize()\n",
    "#plt.scatter(x[:, 1].asnumpy(), x_label[:, 0].asnumpy(), 1);  # 加分号只显示图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "77210598",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]\n",
      " [769.43]]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "a1=a.asnumpy()\n",
    "print(a1)\n",
    "np.savetxt(\"./result.txt\",a1,fmt='%d')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c52cd1fa",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:gluon] *",
   "language": "python",
   "name": "conda-env-gluon-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
